package com.example.wisdomclassroomapi.common.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

/**
 * 标识生成器
 * 可以用来生成数据表主键、业务流水号等
 */
public class IdentificationUtil {
    public Long longId() {
        return Long.valueOf(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")));
    }

    public synchronized String stringId() {
        try{
            Thread.sleep(1L);
        }catch(Exception e){

        }

        return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
    }

    public static String shortUuid() {
        return UUID.randomUUID().toString().replace("-", "");
    }
}
